package edu.mis.modules.role;

import com.jfinal.core.Controller;

import edu.mis.model.Role;

/**
 * 权限控制器
 *
 */
public class RoleController extends Controller {
	
	static RoleService service = new RoleService();
	
	public void index() {
		render("role.html");
	}
	
	public void list(){
		setAttr("data", service.findAllRole());
		renderJson();  
	}

	/**
	 * 添加权限视图
	 */
	public void add() {
		    //render("add.html");  
	}

	public void register(){
		Role role  =  getModel(Role.class);  
		if(service.register(role)){
			setAttr("result", true); 
			setAttr("msg", "添加权限成功!"); 
		}else{
			setAttr("result",false);
			setAttr("msg", "添加失败，权限名重复!"); 
		}
		renderJson(); 
	}
}


